<?php defined('APP_PATH') or exit('Access Denied');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加管理员</title>
<link rel="stylesheet" type="text/css" href="vonuo/static/css/vonuo.css">
<script type="text/javascript" src="vonuo/static/js/jquery.min.js"></script>
<script type="text/javascript">
var ajax_status = false;
function check(){
	if($.trim($("input[name='code']").val()).match(/^[a-z0-9]{5,20}$/g) == null){
		$("#need_code").html("<strong style='color:red;'>账号格式为[5-20]位小写字母和数字组成！</strong>");
		$("input[name='code']").focus();
		return false;
	}else{
		var value = $.trim($("input[name='code']").val());
		var url = "<?php echo spUrl('admin','checkcode');?>";
		$.post(url,{code:value},function(result){
			if(result == '1'){
				$("#need_code").html("<strong style='color:red;'>该账号已存在！</strong>");
			}else if(result == '0'){
				ajax_status = true;
				$("#need_code").html("<strong style='color:red;'>√</strong>");
			}
		});
		if(ajax_status == false){
			return false;
		}
	}
	if($.trim($("input[name='name']").val()) == ''){
		$("#need_name").html("<strong style='color:red;'>请输入管理员姓名！</strong>");
		$("input[name='name']").focus();
		return false;
	}else{
		$("#need_name").html("<strong style='color:red;'>√</strong>");
	}
	if($("select[name='gid']").val() == 'false'){
		$("#need_gid").html("<strong style='color:red;'>请选择管理组！</strong>");
		return false;
	}else{
		$("#need_gid").html("<strong style='color:red;'>√</strong>");
	}
	if($.trim($("input[name='pswd']").val()).match(/^[A-Za-z0-9]{5,20}$/g) == null){
		$("#need_password").html("<strong style='color:red;'>密码格式为[5-20]位字母和数字组成！</strong>");
		$("input[name='pswd']").focus();
		return false;
	}else{
		$("#need_password").html("<strong style='color:red;'>√</strong>");
	}
	if($.trim($("input[name='pswd']").val()) != $.trim($("input[name='pswd2']").val())){
		$("#need_password2").html("<strong style='color:red;'>两次输入的密码不一致！</strong>");
		$("input[name='pswd2']").focus();
		return false;
	}else{
		$("#need_password2").html("<strong style='color:red;'>√</strong>");
	}
	return true;
}
</script>
</head>

<body>
<div class="gs_wraper gs_p_l0">
	<div class="title">
		<a href="javascript:;" class="hover">基本信息</a>
	</div>
	<form action="<?php echo spUrl('admin','doadd');?>" method="post">
	<div class="tab_box" id="con_one_1">
		<table border="0" cellspacing="0" cellpadding="0" class="table_btm">
			<tr>
				<td class="txt_right txt_s_blue">管理账号：</td>
				<td>
					<input name="code" type="text" class="blue_input input_w_175" />
					<span id="need_code"></span>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">管理姓名：</td>
				<td>
					<input name="name" type="text" class="blue_input input_w_175" />
					<span id="need_name"></span>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">所属分组：</td>
				<td>
					<select name="gid" class="blue_input input_w_175 f_left"><option value="false"></option>
					<?php foreach($group as $row){?><option value="<?php echo $row['id'];?>"><?php echo $row['name'];?></option><?php }?>
					</select>
					<span id="need_gid" style="margin-left:8px;"></span>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">登录密码：</td>
				<td>
					<input name="pswd" type="password" class="blue_input input_w_175" />
					<span id="need_password"></span>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue">重复密码：</td>
				<td>
					<input name="pswd2" type="password" class="blue_input input_w_175" />
					<span id="need_password2"></span>
				</td>
			</tr>
			<tr>
				<td class="txt_right txt_s_blue" valign="top">备注信息：</td>
				<td><textarea name="note" cols="40" rows="4" class="blue_textarea"></textarea></td>
			</tr>
			<tr>
				<td></td>
				<td><a href="javascript:;" onclick="if(check()){$('form').submit();}" class="sure_submit f_left time">确 定</a><a href="<?php echo spUrl('group','lis');?>" class="return_btn f_left">返 回</a></td>
			</tr>
		</table>
	</div>
	</form>
</div>
</body>
</html>